# -*- coding: UTF-8 -*-

import os
import glob
import sys

from distutils.file_util import *

import config

class MC:

  def __init__(self):
  	pass

  def mkdir(self, path):
    dirs = []
    #dirs.append(path)
    i =0
    #print path
    while not os.path.exists(path):
      dirs.append(path)
      path = path + "\\.."
      path = os.path.abspath(path)
      #print path
      
      #print path
      #path = os.path.abspath(p)
      #p = p+"\\.."      
      i = i +1
      if i >4:
        print "too deep !"
        break
    
    while len(dirs) > 0:
      dir = dirs.pop()
      os.mkdir(dir)
    
    """
    while len(dirs) > 0:
      dir = dirs.pop(-1)
      #print "pop:"+dir
      if path >  path[0:3] and not os.path.exists(path):
        os.mkdir(path)
      else:
        continue
    """      

        
  def _copy(self, files, dest):
    cwd = os.getcwd()
    source = cwd+"\\"+files
    try:
      copy_file(source, dest)
    except Exception, e:
      print e
      print "files", source
    
  def mcopy(self, globpath, dest):
    files = glob.glob(globpath)
    for file in files:
      self._copy(file, dest)


if __name__ == "__main__":
  mc = MC()

